import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SEntityId } from "../../../../../Message/Public/SEntityId";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
//class GroupLeftCommand
    
    export  class GroupLeftCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc2=null;
            var loc3=0;
            var loc4=null;
            super.call(arg1);
            var loc1=arg1.messageBase as SEntityId;
            if (loc1.id != _cache.role.entityInfo.entityId.id) 
            {
                loc2 = _cache.group.players;
                loc3 = 0;
                while (loc3 < loc2.length) 
                {
                    if ((loc4 = loc2[loc3] as SPublicMiniPlayer).entityId.id == loc1.id) 
                    {
                        MsgManager.showRollTipsMsg(Language.getStringByParam(62031, loc4.name));
                        loc2.splice(loc3, 1);
                        break;
                    }
                    ++loc3;
                }
                NetDispatcher.dispatchCmd(ServerCommand.Group_PlayerInfoChange, null);
            }
            else 
            {
                _cache.group.groupId = null;
                _cache.group.players = [];
                _cache.group.captain = null;
                _cache.group.allocation = -1;
                MsgManager.showRollTipsMsg(Language.getString(62030));
                NetDispatcher.dispatchCmd(ServerCommand.Group_PlayerInfoChange, null);
                NetDispatcher.dispatchCmd(ServerCommand.Group_EnterOrLeaveGroup, null);
            }
            return;
        }
    }
